home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Macintosh Sample Code / SC.023.FracApp 2.0 / URectStack.p < prev   
Encoding:
Text File  |  1990-04-30  |  2.4 KB  |  73 lines  |  [TEXT/MPS ]

  1. {[j=20/53/1$] Pasmat Options}
  2.  
  3. UNIT URectStack;
  4.  
  5. {-------------------------------------------------------------------------------------------
  6.  
  7.     Program:    FracApp 2.0
  8.     Unit:        URectStack
  9.     File:        URectStack.p
  10.     Includes:    URectStack.inc1.p
  11.  
  12.     by Keith Rollin & Bo3b Johnson
  13.     of Apple Macintosh Developer Technical Support
  14.  
  15.     Copyright © 1989-1990 Apple Computer, Inc.
  16.     All rights reserved.
  17.  
  18. --------------------------------------------------------------------------------------------
  19.  
  20.     This unit implements a stack for storing Rects. It defines a TRectStack class
  21.     that is based on the new TDynamicArray class in MacApp 2.0 final. It’s used by
  22.     the fast FracApp engine in keeping track of the areas of the fractal document
  23.     that need to be calculated.
  24.  
  25.     There are 4 major methods of interest. PushRect and PopRect take care of adding
  26.     Rects to and removing Rects from the stack. EachRect is used to iterate over
  27.     all of the  Rects on the stack. This is used by the TFracAppEngine’s DoWrite
  28.     method when it needs to save the stack to disk. Finally, there is the
  29.     ClearStack method that is used to put the stack into a virgin state.
  30.  
  31. --------------------------------------------------------------------------------------------}
  32.  
  33.     INTERFACE
  34.  
  35.         USES UMacApp, Types, Memory;
  36.  
  37.         TYPE
  38.  
  39.             TRectStack            = OBJECT (TDynamicArray)
  40.  
  41.                 PROCEDURE TRectStack.IRectStack(initialNumberOfRects: Integer);
  42.                 { Calls IDynamicArray with “initialNumberOfRects” and an element size of
  43.                   SizeOf(Rect) }
  44.  
  45.                 PROCEDURE TRectStack.ClearStack;
  46.                 { Remove all Rects from the stack. The stack is left empty. }
  47.  
  48.                 PROCEDURE TRectStack.EachRect(PROCEDURE
  49.                                               DoToRect(theRect: Rect); direction: Boolean);
  50.                 { Calls the passed DoToRect procedure for each item on the stack. It traverses
  51.                   the stack in ‘direction’ order. If ‘direction’ is kForward, then we start
  52.                   with the first element pushed onto the stack, and proceed to the last (most
  53.                   recent) element on the stack. }
  54.  
  55.                 PROCEDURE TRectStack.PushRect(theRect: Rect);
  56.                 { Takes the Rect you pass it, and pushes it on the stack. }
  57.  
  58.                 PROCEDURE TRectStack.PopRect(VAR theRect: Rect);
  59.                 { Returns the first Rect on the stack. That Rect is then removed from
  60.                   the stack. }
  61.  
  62.                 PROCEDURE TRectStack.Fields(PROCEDURE
  63.                                             DoToField(fieldName: Str255; fieldAddr: Ptr;
  64.                                                       fieldType: Integer)); OVERRIDE;
  65.  
  66.                 END;
  67.  
  68.     IMPLEMENTATION
  69.  
  70.         {$I URectStack.inc1.p}
  71.  
  72. END.
  73.